﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using FourthWallProject.GameObjects.GameComponents;

namespace FourthWallProject.GameObjects.Solids
{
    abstract class GameObject : DrawableGameComponent
    {
        int _drawOrder;
        bool _visible;
        Texture2D _texture;

        public Texture2D Texture
        {
            get { return _texture; }
            set { _texture = value; }
        }

        Color _color;

        public Color Color
        {
            get { return _color; }
            set { _color = value; }
        }

        public GameObject(Texture2D texture, Rectangle rectangle, Color color,Game game) :base(game)
        {
            _color = color;
            X = rectangle.X;
            Y = rectangle.Y;
            Width = rectangle.Width;
            Height = rectangle.Height;
            _texture = texture;
            Visible = true;
        }

        public float X
        {
            get;
            set;
        }

        public float Y
        { get; set; }

        public Vector2 Position
        {
            get{return new Vector2(X,Y);}
            set { 
                X = value.X; 
                Y = value.Y; 
            }
        }

        public Rectangle Rectangle
        {
            get { return new Rectangle((int)X, (int)Y, (int)this.Width, (int)this.Height); }
        }

        public Rectangle RectangleWithCameraOffset
        {
            get { return new Rectangle(((int)X + GameCamera.X), ((int)Y + GameCamera.Y), (int)Width, (int)Height); }
        }

        public override void Draw(GameTime gameTime)
        {
            ScreenManager.SpriteBatch.Begin();
                ScreenManager.SpriteBatch.Draw(Texture, this.RectangleWithCameraOffset, Color);
            ScreenManager.SpriteBatch.End();
        
        }

        public float Width { get; set; }

        public float Height { get; set; }
    }
}
